]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Add a convenience function for setting an image for ClutterTexture based on GdkPixbuf.
authorMarina Zhurakhinskaya <marinaz@src.gnome.org>
Fri, 21 Nov 2008 00:39:14 +0000 (00:39 +0000)
committerMarina Zhurakhinskaya <marinaz@src.gnome.org>
Fri, 21 Nov 2008 00:39:14 +0000 (00:39 +0000)
svn path=/trunk/; revision=67

src/shell-global.c
src/shell-global.h

index 4652e92fe736dd6b45de336770bc59877300d590..0ae6372a3df2dd571e468960f6ae386ffdfddd7a 100644 (file)
@@ -168,6 +168,31 @@ shell_global_class_init (ShellGlobalClass *klass)
                                                         G_PARAM_READABLE));
 }
 
+/**
+ * shell_clutter_texture_set_from_pixbuf: 
+ * texture: #ClutterTexture to be modified
+ * pixbuf: #GdkPixbuf to set as an image for #ClutterTexture
+ *
+ * Convenience function for setting an image for #ClutterTexture based on #GdkPixbuf.
+ * Copied from an example posted by hp in this thread http://mail.gnome.org/archives/gtk-devel-list/2008-September/msg00218.html
+ *
+ * Return value: %TRUE on success, %FALSE on failure
+ */
+gboolean
+shell_clutter_texture_set_from_pixbuf (ClutterTexture *texture,
+                                       GdkPixbuf      *pixbuf)
+{
+    return clutter_texture_set_from_rgb_data (texture,
+                                              gdk_pixbuf_get_pixels (pixbuf),
+                                              gdk_pixbuf_get_has_alpha (pixbuf),
+                                              gdk_pixbuf_get_width (pixbuf),
+                                              gdk_pixbuf_get_height (pixbuf),
+                                              gdk_pixbuf_get_rowstride (pixbuf),
+                                              gdk_pixbuf_get_has_alpha (pixbuf)
+                                              ? 4 : 3,
+                                              0, NULL);
+}
+
 /**
  * shell_global_get:
  *
index 6f59b811d1238f401e6db7847fdc0aef53e88742..d85796234150b04f218a4f89a61bf9d1ee7f72a7 100644 (file)
@@ -4,6 +4,7 @@
 #include "mutter-plugin.h"
 #include <clutter/clutter.h>
 #include <glib-object.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
 
 G_BEGIN_DECLS
 
@@ -29,6 +30,10 @@ struct _ShellGlobalClass
 
 GType            shell_global_get_type            (void) G_GNUC_CONST;
 
+gboolean
+shell_clutter_texture_set_from_pixbuf (ClutterTexture *texture,
+                                       GdkPixbuf      *pixbuf);
+
 ShellGlobal *shell_global_get (void);
 
 void shell_global_set_stage_input_area (ShellGlobal *global,